import pygame
import sys #退出程序时用到

pygame.init()#初始化pygame

size = width,height = 600,400
screen = pygame.display.set_mode(size)#窗口大小
pygame.display.set_caption('Hello!')#窗口标题
bg = (0,0,0)

font = pygame.font.Font(None,20)
line_height = font.get_linesize()
position = 0

screen.fill(bg)

while True:
    for event in pygame.event.get():#事件队列循环
        if event.type == pygame.QUIT:
            sys.exit()#系统退出

        screen.blit(font.render(str(event),True,(0,255,0)),(0,position))
        #文本渲染为surface，消除锯齿，颜色
        position += line_height

        if position > height:
            position = 0
            screen.fill(bg)

    pygame.display.flip()


    
